from typing import NamedTuple
from typing import Optional

import pytest


class Repo(NamedTuple):
    url: str
    languages: Optional[list] = None
    xfail_reason: Optional[str] = None

    @property
    def short_url(self):
        return self.url.replace("https://github.com/", "gh:")

    def as_param(self):
        return pytest.param(
            self,
            id=self.short_url,
            # we haven't looked at these xfails for a year so might as well just skip them in CI
            marks=pytest.mark.skip if self.xfail_reason is not None else [],
        )


REPOS = [
    # FIXME: Syntax errors in typescript. I made a linear task.
    # Repo("https://github.com/apache/airflow"),
    Repo("https://github.com/coinbase/bifrost"),
    Repo("https://github.com/coinbase/bip38"),
    Repo("https://github.com/coinbase/btcexport"),
    Repo("https://github.com/coinbase/coinbase-android-sdk"),
    Repo("https://github.com/coinbase/coinbase-android-sdk-example"),
    Repo("https://github.com/coinbase/coinbase-bitmonet-sdk"),
    Repo("https://github.com/coinbase/coinbase-commerce-node"),
    Repo("https://github.com/coinbase/coinbase-commerce-python"),
    Repo("https://github.com/coinbase/coinbase-exchange-node"),
    Repo("https://github.com/coinbase/coinbase-java"),
    Repo("https://github.com/coinbase/coinbase-javascript-sdk"),
    Repo("https://github.com/coinbase/coinbase-node"),
    Repo("https://github.com/coinbase/coinbase-python"),
    Repo("https://github.com/coinbase/coinbase-tip-discourse"),
    Repo("https://github.com/coinbase/dexter"),
    Repo("https://github.com/coinbase/fenrir"),
    Repo("https://github.com/coinbase/node-process-lock"),
    Repo("https://github.com/coinbase/odin"),
    Repo("https://github.com/coinbase/protoc-gen-rbi"),
    Repo("https://github.com/coinbase/pwnbot"),
    Repo("https://github.com/coinbase/rosetta-cli"),
    Repo("https://github.com/coinbase/rosetta-sdk-go"),
    Repo("https://github.com/coinbase/self-service-iam"),
    Repo("https://github.com/coinbase/solidity-workshop"),
    Repo("https://github.com/coinbase/step"),
    Repo("https://github.com/coinbase/step-asg-deployer"),
    Repo("https://github.com/coinbase/watchdog"),
    Repo("https://github.com/dropbox/AskBox"),
    Repo("https://github.com/dropbox/Developer-Samples"),
    Repo("https://github.com/dropbox/changes-artifacts"),
    Repo("https://github.com/dropbox/changes-client"),
    Repo("https://github.com/dropbox/changes-lxc-wrapper"),
    Repo("https://github.com/dropbox/changes-mesos-framework"),
    Repo("https://github.com/dropbox/dbx-unittest2pytest"),
    Repo("https://github.com/dropbox/dbxcli"),
    Repo("https://github.com/dropbox/dropbox-api-content-hasher"),
    Repo("https://github.com/dropbox/dropbox-api-v2-repl"),
    Repo("https://github.com/dropbox/dropbox-sdk-go-unofficial"),
    Repo("https://github.com/dropbox/dropbox-sdk-java"),
    Repo("https://github.com/dropbox/dropbox-sdk-js"),
    Repo("https://github.com/dropbox/dropbox-sdk-python"),
    Repo("https://github.com/dropbox/dropbox_hook"),
    Repo("https://github.com/dropbox/emmer"),
    Repo("https://github.com/dropbox/git-rbr"),
    Repo("https://github.com/dropbox/PyHive"),
    Repo("https://github.com/dropbox/goebpf"),
    Repo("https://github.com/dropbox/goprotoc"),
    Repo("https://github.com/dropbox/grallama-panel"),
    Repo("https://github.com/dropbox/hermes"),
    Repo("https://github.com/dropbox/hocrux"),
    Repo("https://github.com/dropbox/hydra"),
    Repo("https://github.com/dropbox/llama"),
    Repo("https://github.com/dropbox/llama-archive"),
    Repo("https://github.com/dropbox/load_management"),
    Repo("https://github.com/dropbox/mdwebhook"),
    Repo("https://github.com/dropbox/mypy-PyCharm-plugin"),
    Repo("https://github.com/dropbox/mypy-protobuf"),
    Repo("https://github.com/dropbox/nsot"),
    Repo("https://github.com/dropbox/othw"),
    Repo("https://github.com/dropbox/pem-converter-maven-plugin"),
    Repo("https://github.com/dropbox/pep8squad"),
    Repo("https://github.com/dropbox/presto-kafka-connector"),
    Repo("https://github.com/dropbox/puppet_run"),
    Repo("https://github.com/dropbox/pyannotate"),
    Repo("https://github.com/dropbox/pygerduty"),
    Repo("https://github.com/dropbox/pynsot"),
    Repo("https://github.com/dropbox/pytest-call-tracer"),
    Repo("https://github.com/dropbox/pytest-flakefinder"),
    Repo("https://github.com/dropbox/python-invariant"),
    Repo("https://github.com/dropbox/revision-browser"),
    Repo("https://github.com/dropbox/rules_node"),
    Repo("https://github.com/dropbox/securitybot"),
    Repo("https://github.com/dropbox/spookify"),
    Repo("https://github.com/dropbox/sqlalchemy-stubs"),
    Repo("https://github.com/dropbox/stone"),
    Repo("https://github.com/dropbox/stopwatch"),
    Repo("https://github.com/dropbox/strongpoc"),
    Repo("https://github.com/dropbox/whitegold"),
    Repo("https://github.com/dropbox/ykfipsconf"),
    Repo("https://github.com/dropbox/zinger"),
    Repo("https://github.com/seemoo-lab/opendrop"),
    Repo("https://github.com/lightstep/lightstep-tracer-python"),
    Repo("https://github.com/getsentry/sentry-python"),
    Repo("https://github.com/signalapp/signal-webrtc-ios"),
    Repo("https://github.com/secdev/scapy"),
    Repo("https://github.com/preset-io/elasticsearch-dbapi"),
    Repo("https://github.com/apache/libcloud"),
    Repo("https://github.com/keybase/pykeybasebot"),
    Repo("https://gitbox.apache.org/repos/asf/cassandra"),
    Repo("https://github.com/keybase/python-triplesec"),
    Repo("https://github.com/psycopg/psycopg2"),
    Repo("https://github.com/preset-io/flask-jwt-extended"),
    Repo("https://github.com/vstinner/pyperf"),
    Repo("https://github.com/mysql/mysql-connector-python"),
    Repo("https://github.com/Netflix/lemur"),
    Repo("https://github.com/mpirnat/lets-be-bad-guys"),
    Repo("https://github.com/JasonHinds13/hackable"),
    Repo("https://github.com/ab-smith/gruyere"),
    Repo("https://github.com/digininja/vuLnDAP"),
    Repo("https://github.com/dropbox/godropbox"),
    Repo("https://github.com/dropbox/trapperkeeper"),
    Repo("https://github.com/lodash/lodash"),
    Repo("https://github.com/0c34/govwa"),
    Repo("https://github.com/coinbase/bittip"),
    Repo("https://github.com/coinbase/multisig-tool"),
    Repo("https://github.com/jekyll/jekyll"),
    Repo("https://github.com/OWASP/NodeGoat"),
    Repo("https://github.com/dropbox/questions"),
    Repo("https://github.com/coinbase/gtt-ui"),
    Repo(
        "https://github.com/DevSlop/Pixi",
        xfail_reason="DevSlop-Pixi/app/public/api-docs/ contains some minified JS files that cause Semgrep to timeout, so the output will contain some errors.",
    ),
    Repo(
        "https://github.com/home-assistant/home-assistant",
        xfail_reason="Lack of support for match statement in Python",
    ),
    Repo("https://github.com/we45/Vulnerable-Flask-App"),
    Repo(
        "https://github.com/draios/sysdig-inspect",
        xfail_reason="Merge conflicts on `dev`, see https://github.com/draios/sysdig-inspect/blob/ee3b8fa9335bf6fc19fd0976d51d87b961db6ebb/testem.js",
    ),
    Repo(
        "https://github.com/rails/rails",
        ["ruby"],
        xfail_reason="https://github.com/tree-sitter/tree-sitter-ruby/issues/167",
    ),
    Repo(
        "https://github.com/highcharts/highcharts",
        xfail_reason="javascript parse error, probably due to '?.01' regression in minified file",
    ),
    Repo(
        "https://github.com/dropbox/incubator-superset-internal",
        xfail_reason="javascript parse error",
    ),
    Repo(
        "https://github.com/coinbase/react-coinbase-commerce",
        xfail_reason="react",
    ),
    Repo(
        "https://github.com/dropbox/DropboxBusinessScripts",
        xfail_reason="https://github.com/returntocorp/semgrep/issues/1498",
    ),
    Repo(
        "https://github.com/dropbox/dbx_build_tools",
        xfail_reason="go parse errors",
    ),
    Repo(
        "https://github.com/dropbox/hackpad",
        xfail_reason="https://www.oreilly.com/library/view/javascript-the-definitive/9781449393854/ch11s06.html",
    ),
    Repo(
        "https://github.com/dropbox/notouch",
        xfail_reason="indented comment on last line python",
    ),
    Repo(
        "https://github.com/rapid7/metasploit-framework",
        ["ruby"],
        xfail_reason="unknown",
    ),
    Repo("https://github.com/Homebrew/brew", ["ruby"], xfail_reason="unknown"),
    Repo("https://github.com/gitlabhq/gitlabhq", ["ruby"], xfail_reason="unknown"),
    Repo(
        "https://github.com/bkimminich/juice-shop",
        ["javascript", "typescript"],
        xfail_reason="Failure to parse typescript",
    ),
    Repo(
        "https://github.com/zulip/zulip",
        ["javascript", "typescript"],
        xfail_reason="Failure to parse typescript",
    ),
    Repo(
        "https://github.com/dropbox/changes",
        xfail_reason="bower/.../insight/.../inquirer/.../rx/.../outro.js is an unbalanced JS fragment",
    ),
    Repo(
        "https://github.com/dropbox/pyston-perf",
        xfail_reason="templates",
    ),
    Repo(
        "https://github.com/opensourceactivismtech/call-power",
        xfail_reason="templates",
    ),
    Repo(
        "https://github.com/dropbox/nautilus-dropbox",
        xfail_reason="dropbox.in is invalid Python",
    ),
]
